package com.yunji.app.system;

import com.yunji.common.base.BaseController;
import com.yunji.common.base.response.Response;
import com.yunji.common.base.response.ResponseHelper;
import com.yunji.common.model.domain.SysDictTypeDO;
import com.yunji.system.service.ISysDictTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Project: yunji-coffee
 * @Package com.yunji.app.system
 * @FileName GateWayDictTypeController.java
 * @Copyright Copyright © 2024 云集互联. All Rights Reserved
 * @Company com
 * @Version 1.0
 * @Since JDK1.8.0_201
 * @CreateTime 2024-06-10 22:48:18
 * @Description 移动端-字典类型信息
 * @Modification History
 * Author					History Time			Version			Description
 * -------------------------------------------------------------------------------
 * HuaAo0803@163.com	2024-06-10 22:48:18		1.0				1.0
 */
@Api(tags = "移动端-字典类型信息")
@RestController
@RequestMapping("/gateway/dict/type")
public class GateWayDictTypeController extends BaseController {
    @Resource
    private ISysDictTypeService dictTypeService;

    @ApiOperation("字典类型列表")
    @GetMapping("/list")
    public Response<List<SysDictTypeDO>> list(SysDictTypeDO dictType) {
        List<SysDictTypeDO> list = dictTypeService.selectDictTypeList(dictType);
        return ResponseHelper.successWithPage(list);
    }

    @ApiOperation("查询字典类型详细")
    @GetMapping(value = "/{dictId}")
    public Response<SysDictTypeDO> getInfo(@PathVariable Long dictId) {
        return ResponseHelper.success(dictTypeService.selectDictTypeById(dictId));
    }

    /**
     * 刷新字典缓存
     */
    @ApiOperation("刷新字典缓存")
    @DeleteMapping("/refreshCache")
    public Response<String> refreshCache() {
        dictTypeService.resetDictCache();
        return ResponseHelper.success();
    }

    /**
     * 获取字典选择框列表
     */
    @ApiOperation("获取字典选择框列表")
    @GetMapping("/optionselect")
    public Response<List<SysDictTypeDO>> optionselect() {
        List<SysDictTypeDO> dictTypes = dictTypeService.selectDictTypeAll();
        return ResponseHelper.success(dictTypes);
    }
}
